﻿using Abp.Application.Services.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace shenghua.Marketing.Coupons.Dto
{
    public class CouponDto: EntityDto
    {
        public string Name { get; set; }
        public double Amount { get; set; }

        public List<int> AppliedCommodityIds { get; set; }

        public double MinAmount { get; set; }
        public int MinCount { get; set; }

        public DateTime Begin { get; set; }
        public DateTime End { get; set; }
        public bool IsOverdue { get; set; }

        /// <summary>
        /// 是否被领取
        /// </summary>
        public bool IsReceived { get; set; }

        public CouponTargetType TargetType { get; set; }
        public int TotalCount { get; set; }
        public bool IsInfinite { get; set; }
        public int GrantedCount { get; set; }
        public int UsedCount { get; set; }
        public int RestCount { get; set; }
        public bool HasRest { get; set; }

        public CouponDto(Coupon coupon)
        {
            Id = coupon.Id;
            Name = coupon.Name;
            Amount = coupon.Amount;

            AppliedCommodityIds = coupon.AppliedCommodityIds.Items;

            MinAmount = coupon.Condition.MinAmount;
            MinCount = coupon.Condition.MinCount;

            Begin = coupon.TimeLimit.Begin;
            End = coupon.TimeLimit.End;
            IsOverdue = coupon.TimeLimit.IsOverdue;

            TargetType = coupon.TargetType;
            TotalCount = coupon.TotalCount;
            IsInfinite = coupon.IsInfinite;
            GrantedCount = coupon.GrantedCount;
            UsedCount = coupon.UsedCount;
            RestCount = coupon.RestCount;
            HasRest = coupon.HasRest;
        }
    }
}
